package cn.wolfcode.luowowo.website.util;

import cn.wolfcode.luowowo.common.exception.LogicalException;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class MyExceptionHandler {


    @ExceptionHandler(LogicalException.class)
    @ResponseBody
    public AjaxResult LogicalExceptionHandler (Exception e) {
        e.printStackTrace();
        return new AjaxResult(false,e.getMessage());
    }


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public AjaxResult xceptionHandler (Exception e) {
        e.printStackTrace();
        return new AjaxResult(false,"系统出现异常");
    }


}
